"""
智象评价L等级和值
"""
# 定义映射
__mappings__ = {
    "L1": 0,
    "L2+": 1,
    "L2": 2,
    "L2-": 3,
    "L3+": 4,
    "L3": 5,
    "L3-": 6,
    "L4+": 7,
    "L4": 8,
    "L4-": 9,
    "L5+": 10,
    "L5": 11,
    "L5-": 12,
    "L6+": 13,
    "L6": 14,
    "L6-": 15,
    "L7": 16,
    "L8": 17,
    "L9": 18
}


# 获取全部定义
def mappings():
    return __mappings__


# L级别转值
def levelToValue(level: str) -> int:
    if level is not None and isinstance(level, str):
        if level in __mappings__.keys():
            return __mappings__.get(level)
    return None


# 值转L级别
def valueToLevel(value: int) -> str:
    if value is not None and isinstance(value, int):
        for k, v in __mappings__.items():
            if v == value:
                return k
                break
    return None
